import 'package:flutter/material.dart';

class MyApp14 extends StatelessWidget {
  const MyApp14({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "ListView.builder使用",
          style: TextStyle(fontSize: 20, color: Colors.white),
        ),
        backgroundColor: Colors.red,
        centerTitle: true,
      ),
      body: Container(
        child: ListView.builder(
          itemCount: 15,
          itemBuilder: (context, index) {
            return Container(
              color: index.isEven ? Colors.blue : Colors.green,
              height: 100,
              width: 100,
              alignment: Alignment.center,
              child: Text("Item $index", style: TextStyle(color: Colors.white)),
            );
          },
        ),
      ),
    );
  }
}
